/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package smartgrid;

import org.orm.PersistentException;
public class SemanaAgregadaProcessor {
	private int ID;
	
	private double domingoPrecoSUM;
	
	private double domingoPrecoAVG;
	
	private double segundaPrecoSUM;
	
	private double segundaPrecoAVG;
	
	private double tercaPrecoSUM;
	
	private double tercaPrecoAVG;
	
	private double quartaPrecoSUM;
	
	private double quartaPrecoAVG;
	
	private double quintaPrecoSUM;
	
	private double quintaPrecoAVG;
	
	private double sextaPrecoSUM;
	
	private double sextaPrecoAVG;
	
	private double sabadoPrecoSUM;
	
	private double sabadoPrecoAVG;
	
	private java.util.Date data;
	
	private String unidade;
	
	private double domingoGastoSUM;
	
	private double domingoGastoAVG;
	
	private double segundaGastoSUM;
	
	private double segundaGastoAVG;
	
	private double tercaGastoSUM;
	
	private double tercaGastoAVG;
	
	private double quartaGastoSUM;
	
	private double quartaGastoAVG;
	
	private double quintaGastoSUM;
	
	private double quintaGastoAVG;
	
	private double sextaGastoSUM;
	
	private double sextaGastoAVG;
	
	private double sabadoGastoSUM;
	
	private double sabadoGastoAVG;
	
	private String action="";
	
	public void setID(int value) {
		this.ID = value;
	}
	
	public int getID() {
		return ID;
	}
	
	public void setDomingoPrecoSUM(double value) {
		this.domingoPrecoSUM = value;
	}
	
	public double getDomingoPrecoSUM() {
		return domingoPrecoSUM;
	}
	
	public void setDomingoPrecoAVG(double value) {
		this.domingoPrecoAVG = value;
	}
	
	public double getDomingoPrecoAVG() {
		return domingoPrecoAVG;
	}
	
	public void setSegundaPrecoSUM(double value) {
		this.segundaPrecoSUM = value;
	}
	
	public double getSegundaPrecoSUM() {
		return segundaPrecoSUM;
	}
	
	public void setSegundaPrecoAVG(double value) {
		this.segundaPrecoAVG = value;
	}
	
	public double getSegundaPrecoAVG() {
		return segundaPrecoAVG;
	}
	
	public void setTercaPrecoSUM(double value) {
		this.tercaPrecoSUM = value;
	}
	
	public double getTercaPrecoSUM() {
		return tercaPrecoSUM;
	}
	
	public void setTercaPrecoAVG(double value) {
		this.tercaPrecoAVG = value;
	}
	
	public double getTercaPrecoAVG() {
		return tercaPrecoAVG;
	}
	
	public void setQuartaPrecoSUM(double value) {
		this.quartaPrecoSUM = value;
	}
	
	public double getQuartaPrecoSUM() {
		return quartaPrecoSUM;
	}
	
	public void setQuartaPrecoAVG(double value) {
		this.quartaPrecoAVG = value;
	}
	
	public double getQuartaPrecoAVG() {
		return quartaPrecoAVG;
	}
	
	public void setQuintaPrecoSUM(double value) {
		this.quintaPrecoSUM = value;
	}
	
	public double getQuintaPrecoSUM() {
		return quintaPrecoSUM;
	}
	
	public void setQuintaPrecoAVG(double value) {
		this.quintaPrecoAVG = value;
	}
	
	public double getQuintaPrecoAVG() {
		return quintaPrecoAVG;
	}
	
	public void setSextaPrecoSUM(double value) {
		this.sextaPrecoSUM = value;
	}
	
	public double getSextaPrecoSUM() {
		return sextaPrecoSUM;
	}
	
	public void setSextaPrecoAVG(double value) {
		this.sextaPrecoAVG = value;
	}
	
	public double getSextaPrecoAVG() {
		return sextaPrecoAVG;
	}
	
	public void setSabadoPrecoSUM(double value) {
		this.sabadoPrecoSUM = value;
	}
	
	public double getSabadoPrecoSUM() {
		return sabadoPrecoSUM;
	}
	
	public void setSabadoPrecoAVG(double value) {
		this.sabadoPrecoAVG = value;
	}
	
	public double getSabadoPrecoAVG() {
		return sabadoPrecoAVG;
	}
	
	public void setData(java.util.Date value) {
		this.data = value;
	}
	
	public java.util.Date getData() {
		return data;
	}
	
	public void setUnidade(String value) {
		this.unidade = value;
	}
	
	public String getUnidade() {
		return unidade == null ? "" : unidade;
	}
	
	public void setDomingoGastoSUM(double value) {
		this.domingoGastoSUM = value;
	}
	
	public double getDomingoGastoSUM() {
		return domingoGastoSUM;
	}
	
	public void setDomingoGastoAVG(double value) {
		this.domingoGastoAVG = value;
	}
	
	public double getDomingoGastoAVG() {
		return domingoGastoAVG;
	}
	
	public void setSegundaGastoSUM(double value) {
		this.segundaGastoSUM = value;
	}
	
	public double getSegundaGastoSUM() {
		return segundaGastoSUM;
	}
	
	public void setSegundaGastoAVG(double value) {
		this.segundaGastoAVG = value;
	}
	
	public double getSegundaGastoAVG() {
		return segundaGastoAVG;
	}
	
	public void setTercaGastoSUM(double value) {
		this.tercaGastoSUM = value;
	}
	
	public double getTercaGastoSUM() {
		return tercaGastoSUM;
	}
	
	public void setTercaGastoAVG(double value) {
		this.tercaGastoAVG = value;
	}
	
	public double getTercaGastoAVG() {
		return tercaGastoAVG;
	}
	
	public void setQuartaGastoSUM(double value) {
		this.quartaGastoSUM = value;
	}
	
	public double getQuartaGastoSUM() {
		return quartaGastoSUM;
	}
	
	public void setQuartaGastoAVG(double value) {
		this.quartaGastoAVG = value;
	}
	
	public double getQuartaGastoAVG() {
		return quartaGastoAVG;
	}
	
	public void setQuintaGastoSUM(double value) {
		this.quintaGastoSUM = value;
	}
	
	public double getQuintaGastoSUM() {
		return quintaGastoSUM;
	}
	
	public void setQuintaGastoAVG(double value) {
		this.quintaGastoAVG = value;
	}
	
	public double getQuintaGastoAVG() {
		return quintaGastoAVG;
	}
	
	public void setSextaGastoSUM(double value) {
		this.sextaGastoSUM = value;
	}
	
	public double getSextaGastoSUM() {
		return sextaGastoSUM;
	}
	
	public void setSextaGastoAVG(double value) {
		this.sextaGastoAVG = value;
	}
	
	public double getSextaGastoAVG() {
		return sextaGastoAVG;
	}
	
	public void setSabadoGastoSUM(double value) {
		this.sabadoGastoSUM = value;
	}
	
	public double getSabadoGastoSUM() {
		return sabadoGastoSUM;
	}
	
	public void setSabadoGastoAVG(double value) {
		this.sabadoGastoAVG = value;
	}
	
	public double getSabadoGastoAVG() {
		return sabadoGastoAVG;
	}
	
	public String getAction() {
		return action;
	}
	
	public void setAction(String action) {
		this.action = action;
	}
	
	private int contract_contractID;
	
	public void setContract_contractID(int value) {
		this.contract_contractID = value;
	}
	
	public int getContract_contractID() {
		return contract_contractID;
	}
	
	public String process() {
		String result = "Unexcepted result";
		if (action.equals("search")) {
			smartgrid.SemanaAgregada _semanaAgregada = smartgrid.SemanaAgregada.loadSemanaAgregadaByORMID(getID());
			if (_semanaAgregada!= null) {
				copyFromBean(_semanaAgregada);
				result = "Search success";
			}
			else {
				result = "Search failed";
			}
		}
		else if(action.equals("insert"))  {
			try {
				smartgrid.SemanaAgregada _semanaAgregada = smartgrid.SemanaAgregada.createSemanaAgregada();
				copyToBean(_semanaAgregada);
				if (_semanaAgregada.save()) {
					result = "Insert success";
				}
				else {
					result = "Insert failed";
				}
			}
			catch (Exception e) {
				result = "Insert error: " + e.toString();
			}
		}
		else if (action.equals("update")) {
			smartgrid.SemanaAgregada _semanaAgregada= smartgrid.SemanaAgregada.loadSemanaAgregadaByORMID(getID());
			if (_semanaAgregada != null) {
				copyToBean(_semanaAgregada);
				if (_semanaAgregada.save()) {
					result = "Update success";
				}
				 else {
					result = "Update failed";
				}
			}
			 else  {
				result = "Update failed";
			}
			
		}
		else if (action.equals("delete")) {
			smartgrid.SemanaAgregada _semanaAgregada = smartgrid.SemanaAgregada.loadSemanaAgregadaByORMID(getID());
			if (_semanaAgregada != null && _semanaAgregada.deleteAndDissociate()) {
				result = "Delete success";
			}
			else {
				result = "Delete failed";
			}
		}
		else if (action.equals("")) {
			result = "";
		}
		action = "";
		return result;
	}
	
	private void copyFromBean(smartgrid.SemanaAgregada _semanaAgregada) {
		setDomingoPrecoSUM(_semanaAgregada.getDomingoPrecoSUM());
		setDomingoPrecoAVG(_semanaAgregada.getDomingoPrecoAVG());
		setSegundaPrecoSUM(_semanaAgregada.getSegundaPrecoSUM());
		setSegundaPrecoAVG(_semanaAgregada.getSegundaPrecoAVG());
		setTercaPrecoSUM(_semanaAgregada.getTercaPrecoSUM());
		setTercaPrecoAVG(_semanaAgregada.getTercaPrecoAVG());
		setQuartaPrecoSUM(_semanaAgregada.getQuartaPrecoSUM());
		setQuartaPrecoAVG(_semanaAgregada.getQuartaPrecoAVG());
		setQuintaPrecoSUM(_semanaAgregada.getQuintaPrecoSUM());
		setQuintaPrecoAVG(_semanaAgregada.getQuintaPrecoAVG());
		setSextaPrecoSUM(_semanaAgregada.getSextaPrecoSUM());
		setSextaPrecoAVG(_semanaAgregada.getSextaPrecoAVG());
		setSabadoPrecoSUM(_semanaAgregada.getSabadoPrecoSUM());
		setSabadoPrecoAVG(_semanaAgregada.getSabadoPrecoAVG());
		setData(_semanaAgregada.getData());
		setUnidade(_semanaAgregada.getUnidade());
		setDomingoGastoSUM(_semanaAgregada.getDomingoGastoSUM());
		setDomingoGastoAVG(_semanaAgregada.getDomingoGastoAVG());
		setSegundaGastoSUM(_semanaAgregada.getSegundaGastoSUM());
		setSegundaGastoAVG(_semanaAgregada.getSegundaGastoAVG());
		setTercaGastoSUM(_semanaAgregada.getTercaGastoSUM());
		setTercaGastoAVG(_semanaAgregada.getTercaGastoAVG());
		setQuartaGastoSUM(_semanaAgregada.getQuartaGastoSUM());
		setQuartaGastoAVG(_semanaAgregada.getQuartaGastoAVG());
		setQuintaGastoSUM(_semanaAgregada.getQuintaGastoSUM());
		setQuintaGastoAVG(_semanaAgregada.getQuintaGastoAVG());
		setSextaGastoSUM(_semanaAgregada.getSextaGastoSUM());
		setSextaGastoAVG(_semanaAgregada.getSextaGastoAVG());
		setSabadoGastoSUM(_semanaAgregada.getSabadoGastoSUM());
		setSabadoGastoAVG(_semanaAgregada.getSabadoGastoAVG());
		setID(_semanaAgregada.getORMID());
		
		{
			smartgrid.Contract _contract = _semanaAgregada.getContract();
			if (_contract != null) {
				setContract_contractID(_contract.getORMID());
			}
		}
		
	}
	
	private void copyToBean(smartgrid.SemanaAgregada _semanaAgregada) {
		_semanaAgregada.setDomingoPrecoSUM(getDomingoPrecoSUM());
		_semanaAgregada.setDomingoPrecoAVG(getDomingoPrecoAVG());
		_semanaAgregada.setSegundaPrecoSUM(getSegundaPrecoSUM());
		_semanaAgregada.setSegundaPrecoAVG(getSegundaPrecoAVG());
		_semanaAgregada.setTercaPrecoSUM(getTercaPrecoSUM());
		_semanaAgregada.setTercaPrecoAVG(getTercaPrecoAVG());
		_semanaAgregada.setQuartaPrecoSUM(getQuartaPrecoSUM());
		_semanaAgregada.setQuartaPrecoAVG(getQuartaPrecoAVG());
		_semanaAgregada.setQuintaPrecoSUM(getQuintaPrecoSUM());
		_semanaAgregada.setQuintaPrecoAVG(getQuintaPrecoAVG());
		_semanaAgregada.setSextaPrecoSUM(getSextaPrecoSUM());
		_semanaAgregada.setSextaPrecoAVG(getSextaPrecoAVG());
		_semanaAgregada.setSabadoPrecoSUM(getSabadoPrecoSUM());
		_semanaAgregada.setSabadoPrecoAVG(getSabadoPrecoAVG());
		_semanaAgregada.setData(getData());
		_semanaAgregada.setUnidade(getUnidade());
		_semanaAgregada.setDomingoGastoSUM(getDomingoGastoSUM());
		_semanaAgregada.setDomingoGastoAVG(getDomingoGastoAVG());
		_semanaAgregada.setSegundaGastoSUM(getSegundaGastoSUM());
		_semanaAgregada.setSegundaGastoAVG(getSegundaGastoAVG());
		_semanaAgregada.setTercaGastoSUM(getTercaGastoSUM());
		_semanaAgregada.setTercaGastoAVG(getTercaGastoAVG());
		_semanaAgregada.setQuartaGastoSUM(getQuartaGastoSUM());
		_semanaAgregada.setQuartaGastoAVG(getQuartaGastoAVG());
		_semanaAgregada.setQuintaGastoSUM(getQuintaGastoSUM());
		_semanaAgregada.setQuintaGastoAVG(getQuintaGastoAVG());
		_semanaAgregada.setSextaGastoSUM(getSextaGastoSUM());
		_semanaAgregada.setSextaGastoAVG(getSextaGastoAVG());
		_semanaAgregada.setSabadoGastoSUM(getSabadoGastoSUM());
		_semanaAgregada.setSabadoGastoAVG(getSabadoGastoAVG());
		smartgrid.Contract _contract = smartgrid.Contract.loadContractByORMID(getContract_contractID());
		_semanaAgregada.setContract(_contract);
	}
	
}

